﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication3
{
    public partial class FormBase : Form
    {
        ToolStripMenuItem m_tsMi = null;
        public FormBase()
        {
            InitializeComponent();
        }

        public FormBase(ToolStripMenuItem tsMi)
        {
            InitializeComponent();
            m_tsMi = tsMi;
            if (m_tsMi != null)
            {
                m_tsMi.Enabled = false;
                if (m_tsMi.OwnerItem.Owner.Items.Count > 0)
                {
                    ToolStripMenuItem tsWinMenu = (ToolStripMenuItem)m_tsMi.OwnerItem.Owner.Items[m_tsMi.OwnerItem.Owner.Items.Count - 1];
                    ToolStripMenuItem tsMiNew = new ToolStripMenuItem(m_tsMi.Text);
                    tsMiNew.Tag = this;
                    this.Tag = tsMiNew;
                    tsWinMenu.DropDownItems.Add(tsMiNew);
                }
            }
        }

        private void FormBase_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (m_tsMi != null)
                m_tsMi.Enabled = true;
        }
    }
}
